<template>
	<div class="exercises-test exercises-test-exercises" v-loading.fullscreen.lock="loading"
		element-loading-text="拼命加载中">
        <el-row class="preview-head" type="flex" align="middle">
            <el-col :span="2" :offset="1">
                <el-button type="text" @click="goBack()"><i class="el-icon-arrow-left"></i>返回</el-button>
            </el-col>
        </el-row>

		<div class="preview-conten maxW">
			
			<div class="preview-conten-l">
				
				<div class="preview-conten-l-h">
					<h3>错本题练习</h3>
					<!-- <p>考试时间：120分钟，满分100分</p> -->
					
				</div>
				<div class="exercises-test-type">
					<a :href=" '#'+ item.id" v-for="item of questionTyle">{{item.name}}</a>
					<el-radio-group v-model="question.type" v-if="0">
						<template v-for="item of questionTyle">
							<el-radio v-if="item" :label="item.id">{{item.name}}</el-radio>
						</template>
					</el-radio-group>
				</div>

				<ul>
					<li :id="type.id" class="preview-conten-list" v-for="(item, index) of testList">
						
						<div class="preview-conten-title" v-if="type.type_id === type.id">
							 <span><i>{{typeName[index
							 ]}}. </i>{{item.question_type_name}}</span>
						</div>

						<ul class="preview-conten-subject">

							<!-- <template  v-for="(item, index) of type.children"> -->
								<template v-if="type.type_id === type.id">
									
					
									<li :id="item.id" class="preview-conten-subject-c exercises-question" v-if="parseInt(item.type_base_id) == 1" :key="index">
										<!-- <template v-if="item.show"> -->
										<div  v-if="item.pattern === 1" class="preview-conten-subject-t">
											<i>{{index+1}}. </i>
											<span v-html="item.content"></span>
											
										</div>
										<div  v-if="item.pattern === 2" class="preview-conten-subject-t">
											<i>{{index+1}}. </i>
											<!-- <span v-html="item.content"></span> -->
											<img :src="item.content">
											<strong v-if="item.score">({{item.score}}分)</strong>
										</div>
										<!-- </template> -->
										<transition name="el-fade-in-linear">
											<i v-if="item.html_bool == 1" class="el-icon-check exercises-test-result"></i>
											<i v-if="item.html_bool == 2" class="el-icon-close exercises-test-result"></i>
										</transition>

										<el-radio-group v-model="item.answer" @change="setChecked($event, item)">
											<ul class="preview-topic">

												<template  v-for="(option,key) in item.option"   >
													<li class="preview-subject-title" :class="item.pattern == 2 ? 'option-pattern' : ''">
														<el-radio  :label="option.name"  :disabled="item.disabled"></el-radio>
														<div class="" v-html="option.value" v-if="item.pattern == 1"></div>
													</li>
												</template>
												
											</ul>
										</el-radio-group>

										<div class="exercises-test-btn">
											<el-button v-show="item.qiang_bool == 1" type="primary" @click="selectAnswerChange(item, 1)">提交</el-button>
											<el-button v-show="item.qiang_bool == 0" type="primary" disabled>提交</el-button>
											<!-- <a class="accordion-open"   @click.stop="operationTest(item, list, index)">移出错题本</a> -->
											<transition name="el-fade-in-linear">
												<span v-show="item.disabled == true" >正确答案：<i>{{item.correct_answer[0]}}</i></span>
											</transition>
											<!-- <el-button v-show="item.qiang_bool == 2" type="primary" disabled>提交</el-button> -->
										</div>

										<el-collapse accordion class="preview-answer" v-if="0">
											<el-collapse-item>
												<template slot="title">
													<div class="preview-accordion-title">
														<span>题型：{{item.question_type}}</span>
														<span>难度： {{item.difficulty}}</span>
														<span v-if="item.keynote == 1">重点程度： 低</span>
														<span v-if="item.keynote == 2">重点程度： 中</span>
														<span v-if="item.keynote == 3">重点程度： 高</span>
													</div>
													
												</template>


												<div class="preview-accordion-answer">
													<span>正确答案： </span>
													<div>
														<i v-for="answer of item.answer">{{answer}}</i>
													</div>
												</div>
												
												<div class="preview-accordion-answer">
													<span>解析： </span>
													<template v-if="item.pattern == 1">
														<div v-html="item.resolve"></div>
													</template>
													<template v-if="item.pattern == 2">
														<div>
															<img :src="BASE_URL + item.resolve_path">
														</div>
													</template>
												</div>
											</el-collapse-item>
										</el-collapse>
									</li>

									<li :id="item.id" class="preview-conten-subject-c exercises-question" v-else-if="parseInt(item.type_base_id) == 2" :key="index">
										<template>
											<div  v-if="item.pattern === 1" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												
											</div>
											<div  v-if="item.pattern === 2" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<!-- <span v-html="item.content"></span> -->
												<img :src="item.content" >
												<strong v-if="item.score">({{item.score}}分)</strong>
											</div>
										</template>
										<transition name="el-fade-in-linear">
											<i v-if="item.html_bool == 1" class="el-icon-check exercises-test-result"></i>
											<i v-if="item.html_bool == 2" class="el-icon-close exercises-test-result"></i>
										</transition>
										
										<ul class="preview-topic">
											<template  v-for="(option,key) in item.option">
												
												<li class="preview-subject-title" v-if="item.pattern === 1" >
													<el-checkbox  :disabled="item.disabled"
													@change="selectAnswer($event, index,  key, item.question_id, option.name, item)"
													:label="option.name"></el-checkbox>
													<div class="" v-html="option.value"></div>
												</li>

												<li class="preview-subject-title option-pattern" v-if="item.pattern === 2" >
													<el-checkbox  :disabled="item.disabled"
													@change="selectAnswer($event,  index,  key,  item.question_id, option.name, item)"
													:label="option.name"></el-checkbox>
													<!-- <div class="" v-html="option.value"></div> -->
												</li>
											</template>
											
										</ul>

										<div class="exercises-test-btn">
											<el-button v-show="item.qiang_bool == 1" type="primary" @click="selectAnswerChange(item, 2)">提交</el-button>
											<el-button v-show="item.qiang_bool == 0" type="primary" disabled>提交</el-button>
												<!-- <a class="accordion-open"   @click.stop="operationTest(item, list, index)">移出错题本</a> -->
											<transition name="el-fade-in-linear">
												<span v-show="item.disabled == true" >正确答案：
													<i v-for="val of item.correct_answer"> {{val}}</i>
												</span>
											</transition>
										</div>
									</li>

									<li :id="item.id" class="preview-conten-subject-c exercises-question" v-else-if="parseInt(item.type_base_id) == 4" :key="index">
										<template>
											<div  v-if="item.pattern === 1" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												
											</div>
											<div  v-if="item.pattern === 2" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												<strong v-if="item.score">({{item.score}}分)</strong>
											</div>
										</template>
										<i v-if="item.html_bool == 1" class="el-icon-check exercises-test-result"></i>
										<i v-if="item.html_bool == 2" class="el-icon-close exercises-test-result"></i>

										

										<el-radio-group v-model="item.answer" @change="setChecked($event, item)">
											<ul class="preview-topic">

												<template  v-for="(option,key) in item.option"  v-if="item.pattern === 1" >
													<li class="preview-subject-title" >
														<el-radio :label="option.name" ></el-radio>
														<!-- <div class="" v-html="option.value"></div> -->
													</li>
													<li class="preview-subject-title option-pattern"  v-if="item.pattern === 2" >
														<el-radio :label="option.name" ></el-radio>
														<!-- <div class="" v-html="option.value"></div> -->
													</li>
												</template>
												
											</ul>
										</el-radio-group>

										<div class="exercises-test-btn">
											<el-button v-show="item.qiang_bool == 1" type="primary" @click="selectAnswerChange(item, 9)">提交</el-button>
											<el-button v-show="item.qiang_bool == 0" type="primary" disabled>提交</el-button>
												<!-- <a class="accordion-open"   @click.stop="operationTest(item, list, index)">移出错题本</a> -->
											<transition name="el-fade-in-linear">
												<span v-show="item.disabled == true" >正确答案：
													<i > {{item.correct_answer[0]}}</i>
												</span>
											</transition>
										</div>
									</li>

									<li :id="item.id" class="preview-conten-subject-c"   v-else-if="parseInt(item.type_base_id) === 3"  :key="index">

										<template>
											<div  v-if="item.pattern === 1" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												<strong v-if="item.score">({{item.score}}分)</strong>
											</div>
											<div  v-if="item.pattern === 2" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												<strong>({{item.score}}分)</strong>
											</div>
										</template>
										
										<div class="knowledge-answer">
											<span>答案</span>
											<div class="knowledge-">
												<template v-for="num of item.answerArr">

													<textarea class="knowledge-textarea" rows="2"  @input="editorChange($event, item)"  v-model.trim.native="num.answer" placeholder="请输入内容, 300个字符内" maxlength="300" :disabled="item.disabled"></textarea>
												</template>
											</div>
										</div>

										<div class="exercises-test-btn">
											<el-button v-show="item.qiang_bool == 1" type="primary" @click="selectAnswerChange(item, 3)">提交</el-button>
											<el-button v-show="item.qiang_bool == 0" type="primary" disabled>提交</el-button>
												<!-- <a class="accordion-open"   @click.stop="operationTest(item, list, index)">移出错题本</a> -->
										</div>
										
										 <transition name="el-zoom-in-top">
											<el-collapse accordion class="preview-answer"  v-show="item.html_bool && item.disabled">
												<el-collapse-item>
													<template slot="title">
														<div class="accordion-operate" @click.stop="">
															<a class="accordion-open" @click="collection(item)">收藏本题</a>
														</div>
													</template>
													
													<div class="preview-accordion-answer">
														<span>解析： </span>
														<template v-if="item.pattern == 1">
															<div v-html="item.resolve"></div>
														</template>
														<template v-if="item.pattern == 2">
															<div>
																<img :src="BASE_URL + item.resolve_path">
															</div>
														</template>
													</div>
												</el-collapse-item>
											</el-collapse>
										</transition>
									</li>

									<li :id="item.id" class="preview-conten-subject-c" v-else :key="index">
										<template>
											<div  v-if="item.pattern === 1" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<span v-html="item.content"></span>
												<strong v-if="item.score">({{item.score}}分)</strong>
											</div>
											<div  v-if="item.pattern === 2" class="preview-conten-subject-t">
												<i>{{index+1}}. </i>
												<img :src="item.content">
												
											</div>
										</template>

										<i v-show='item.qiang_bool == 3' class="el-icon-time exercises-test-result"></i>

										<template>
											<div class="knowledge-answer">
												<span>答案</span>
												<div class="knowledge-" >

													<Ueditor  v-model="item.answer" :ref="'Ueditor'+item.id" :writeMsg="item.answer" 
													 :id="'answers'+(index+1)"  :config="config1"  
													 @input="editorChange($event, item)" ></Ueditor> 

												</div>
											</div>


										</template>
										
										

										<div class="exercises-test-btn">
											<el-button v-show="item.qiang_bool == 1" type="primary" @click="selectAnswerChange(item, 4)">提交</el-button>
											<el-button v-show="item.qiang_bool == 0" type="primary" disabled>提交</el-button>
												<!-- <a class="accordion-open"   @click.stop="operationTest(item, list, index)">移出错题本</a> -->
										</div>
										
										 <transition name="el-zoom-in-top">
											<el-collapse accordion class="preview-answer" v-show="item.html_bool && item.disabled">
												<el-collapse-item>
													
													<template slot="title">
														<div class="accordion-operate" @click.stop="">
															<a class="accordion-open" @click="collection(item)">收藏本题</a>
														</div>
													</template>
													<div class="preview-accordion-answer">
														<span>解析： </span>
														<template v-if="item.pattern == 1">
															<div v-html="item.resolve"></div>
														</template>
														<template v-if="item.pattern == 2">
															<div>
																<img :src="item.resolve">
															</div>
														</template>
													</div>
												</el-collapse-item>
											</el-collapse>
										</transition>
										
									</li>

								</template>
							<!-- </template> -->

						</ul>
					</li>


				</ul>
			</div>

			<div class="exercises-conten-r">

				<ul class="exercises-conten-r-type">
					<li class="exercises-conten-r-type-title">答题卡</li>
					
					<template  v-for="(type, list) of questionTyle" >
						<li class="exercises-conten-r-type-state exercises-result-state">
							<div>{{type.name}}<i></i></div>
							<ul>
								<template  v-for="(item, index) of type.children">
									<li  v-if="parseInt(item.type_id) == parseInt(type.id)" :key="index" >
										<!-- <template v-if="isPraise == 0 ">
											<span  class="exercises-praise">{{++index}}</span>
										</template> -->
										<input type="checkbox" :name="index" :checked="item.html_default">
										<template>
											<a :href=" '#'+item.id " v-if="item.html_bool == 0" class="exercises-unanswered">{{++index}}</a>
											<a :href=" '#'+item.id " v-else-if="item.html_bool == 1 " class="exercises-success">{{++index}}</a>
											<a :href=" '#'+item.id " v-else-if="item.html_bool == 2" class="exercises-error">{{++index}}</a>
											<a :href=" '#'+item.id " v-else-if="item.html_bool == 4" class="exercises-info">{{++index}}</a>
										</template>
										
									</li>
								</template>
							</ul>
						</li>
					</template>
						
				</ul>
				
				<div class="exercises-answer-state exercises-cc">
					<span>正确<i></i></span>
					<span>未答<i></i></span>
					<span>错误<i></i></span>
					<span>已答<i></i></span>
				</div>

			</div>
		</div>

		<!-- 预览图片 -->
		<image-viewer 
            v-if="imagePreview.showViewer"
            :initial-index="imageIndex"
            :on-close="closeViewer"
            :url-list="imagePreview.previewSrcList">
        </image-viewer>
	</div>
</template>

<script>

	import Ueditor from '@/components/common/Ueditor.vue';
	export default {
		components: {Ueditor},
		data(){
			return {
				imagePreview: {/*图片预览*/
					showViewer: false,
					previewSrcList: []
				},
				radio: '',
				headClassList: null,
				type: 1,
				checkList: [],
				tasksVisible: false,
				question: {
					type: 0,			/*题型*/
					difficulty: 0,		/*难度*/
					keyword: '',		/*关键字*/
					subject: this.$route.query.id,		/*科目id*/
					page: 1,			/*分页参数*/
					size: 10			/*分页参数*/
				},

				testList:[],		/* 试卷列表 */
				answerList: [],		/* 试卷答案 */
				questionTyle:[],


				loading: true,
				imgIndex: 0,
				typeName: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五', '十六'],

		        config1: {
		        	zIndex: 3,
		        	textIndent: 0,
		        	maximumWords: 2000,
		        	elementPathEnabled: false,/*元素路径*/
		        	enableAutoSave: false,
					autoHeightEnabled: false,
					autoFloatEnabled: false,//不允许滚动时固定在顶部
					initialContent:'请输入内容...',   //初始化编辑器的内容,也可以通过textarea/script给值，看官网例子
					autoClearinitialContent:true, //是否自动清除编辑器初始内容，注意：如果focus属性设置为true,这个也为真，那么编辑器一上来就会触发导致初始化的内容看不到了
					initialFrameWidth: '100%',
					initialFrameHeight: 100,
					serverUrl: this.BASE_URL+"/static/_/UEditor/1.4.3//php/controller.php?action=uploadimage",
					BaseUrl: this.BASE_URL,
					UEDITOR_HOME_URL: process.env.BASE_URL ? process.env.BASE_URL + 'ueditor/' : '/static/ueditor/',
					toolbars: [
						['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'pasteplain',  'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc','fullscreen',  'simpleupload','link', 'justifyleft', 'justifyright', 'justifycenter', 'lineheight', 'fontfamily', 'fontsize', 'undo', 'redo']
					]
		        },

			}
		},
		mounted(){
			this.headClassList = document.querySelector('#trunk').classList;
			this.headClassList.add('hidden-header')

			document.querySelector('.preview-conten-l').addEventListener('click',  (e)=> {
				
				let [targetSrc ,imgs, srcArr, currentIdx] = ['', '', '', '']
				if (e.target.nodeName === 'IMG') {

					this.imagePreview.showViewer = true
					targetSrc = e.target.src;
					imgs = [...e.target.parentNode.children];
					srcArr = imgs.map(item=>item.currentSrc);
					currentIdx = srcArr.indexOf(targetSrc);

					this.imagePreview.previewSrcList = srcArr
					this.imgIndex = targetSrc

				}
			
			}, false)

			this.$nextTick(()=>{
				this.getTestList()
			})

			
		},
		computed: {
			imageIndex() {
			    return this.imagePreview.previewSrcList.indexOf(this.imgIndex);
			}

		},
		destroyed(){
			this.headClassList.remove('hidden-header')
		},
		created(){
			
		},
		
		methods: {
			/**
			 * 关闭图片
			 * @DateTime 2020-04-16T17:40:41+0800
			 * @qiu_m
			 * @return   {[type]}                 [description]
			 */
			 closeViewer() {
			 	this.imagePreview.showViewer = false;
			 	this.imagePreview.previewSrcList = []
			 },
			/**
			 * 
			 * @qiu_m
			 * @DateTime 2019-12-03T18:43:35+0800
			 * @param    {[type]}                 obj [description]
			 * @return   {[type]}                     [description]
			 */
			collection(obj){
				this.$confirm('确定要将该试题收藏到我的题库吗？', '收藏', {
					cancelButtonText: '取消',
					confirmButtonText: '确定',
					type: 'warning',
					customClass: "myHomework"
				}).then(() => {

					let success = (res=>{
						this.$message.success(res.msg)
					})
					let params = {id: obj.id}
					
					this.$ajax.post('api/newtest/fav_test_question', params, {func: {success: success}})
				}).catch(() => {});
			},
			operationTest(obj, one, two){
				// console.log(obj)

				this.$confirm('是否移出错题本？', '移出', {
					cancelButtonText: '取消',
					confirmButtonText: '确定',
					type: 'warning',
					customClass: "test-message"
				}).then(() => {
					
					let success = (res=>{
						this.$message.success(res.msg)
						obj.show = false
					
					});

					this.$ajax({
						url: 'api/newtest/error_question',
						method: 'delete',
						params: {id: obj.id},
						func: {success: success}
					})
				}).catch(() => {});
			},
			/**
			 * 监听答案富文本状态
			 * @DateTime 2019-08-28T15:46:22+0800
			 * @param    {[type]}                 e   [description]
			 * @param    {[type]}                 obj [description]
			 * @return   {[type]}                     [description]
			 */
			editorChange(e, obj){

				/*填空题*/
				if (obj.answerArr) {
					let flas = false
					obj.answerArr.forEach((item, index) =>{

						if (item) {
							
							if (item.answer != '') {
								flas= true
								obj.answer = `${item.answer}`
							}


						}
					})
				
					if (flas) {
						obj.qiang_bool = 1
						obj.html_bool = 4 
					}else{
						obj.qiang_bool = 0
						 obj.html_bool = 0
					}


				}else{
					if (obj.answer != '') {
						obj.qiang_bool = 1
						obj.html_bool = 4 
					}else{
						obj.qiang_bool = 0
						 obj.html_bool = 0
					}
				}

				// obj.answer != '' ? obj.qiang_bool = 1 : obj.qiang_bool = 0
			},
			/**
			 * 监听单选题的状态
			 * @DateTime 2019-08-28T15:20:06+0800
			 * @param    {[type]}                 val [description]
			 * @param    {[type]}                 obj [description]
			 */
			setChecked(val, obj){
				val ? obj.qiang_bool = 1 : obj.qiang_bool = 0;
				val ? obj.html_bool = 4 : obj.html_bool = 0;
			},
			/**
			 * 根据参数请求试卷详情
			 * @DateTime 2019-07-22T17:37:30+0800
			 * @return   {[type]}                 [description]
			 */
			getTestList(){
				let success = (res=>{
					this.testList = res.data;
					this.answerLis = []

					let idArray = []
					let array = []
					let typeArr = ['0', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五', '十六']; /*新建-试卷的中文123*/
					this.testList.forEach((item, key)=>{
						// item.disabled = false

						this.$set(Object.assign(item, {"disabled": false})) 

						if (item.type_base_id == 1 || item.type_base_id == 2 || item.type_base_id == 4) {
							item.correct_answer =  item.correct_answer != '' ? JSON.parse(item.correct_answer) : '';
							item.error_answer =  item.error_answer != '' ? item.error_answer : [];
							item.option = item.option != '' ? JSON.parse(item.option) : [];	

							item.html_bool = 0,
							item.qiang_bool = 0
						}else{
							item.error_answer =  item.error_answer ;
							item.answer	 = null
							item.qiang_bool = 0
							item.answer = ''
						}

						if (item.type_base_id == 3) {

								let count = 0;
								let answerArr = []
								for (var i = 0; i < item.blank_num; i++) {
						
									answerArr.push({'answer': ''})
								}
								item.answerArr = [];
								this.$set(Object.assign( item.answerArr,  answerArr))
								// count++;
						}

						this.$set(Object.assign(item,{show: true}))
						
						/*答案*/
						this.answerList[item.question_id] = {
							id: item.question_id,
							status: 0,
							answer: '',
							type: item.type_base_id,
							errorAnswer: item.error_answer,
							correcAnswer: item.correct_answer 
						}


						if (!idArray.includes(item.type_id)) {
							array[item.type_id] = {

								id: item.type_id,
								name: item.question_type_name,
								type: typeArr[item.type_id],
								children: []
							}
						}

						idArray.push(item.type_id)
						idArray = [...new Set(idArray)]

						array.forEach((len, index)=>{
							if (len.id == item.type_id) {
								this.$set(Object.assign(item, {"disabled": false})) 
								len.children.push(item)

							}
							
						})

						
					});


					array.forEach(item=> {
						if (item.id) {

							this.questionTyle.push(item)
						}

					})
				/*	this.$nextTick(()=>{

						//改变试题 img 的 url
						let imgArr = document.querySelectorAll('.preview-conten-subject-c img')
						let baseUrl = sessionStorage.getItem('host_addr');
						for (var i = 0; i < imgArr.length; i++) {
							let _temp = imgArr[i].src
							imgArr[i].src = _temp.replace(location.protocol+'//'+location.host, baseUrl);
						}

					})*/
					this.loading = false
				});
				let params = {
					user_id: this.$g.user_id,
					type_id: this.question.type,
					subject_id: this.question.subject,/*科目id*/
					difficulty_id: this.question.difficulty,/*难度id*/
					page_index: this.question.page,
					// page_size: this.question.size,

				};

				let fail = (res=>{
					this.$message.error({
						duration: 8000,
						message: res.msg
					})
				})

				this.$ajax({
					url: 'api/newtest/error_question',
					method: 'get',
					params: params,
					func: {success: success, fail: fail}
				})
			},
			/**
			 * 是否提交试卷？”
			 */
			submitQuestions(id){
				this.$confirm('是否提交试卷？', '提示', {
				   confirmButtonText: '确认',
				   cancelButtonText: '取消',
				    type: 'warning',
				    customClass: 'confirm-them',
				}).then(() => {

				    
				}).catch(() => {});
			},

			 /**
			  * 返回上一页
			  * @return {[type]} [description]
			  */
			 goBack(){

			 	this.$confirm('返回上一页，数据不作保存', '提示', {
			 		confirmButtonText: '确定',
			 		cancelButtonText: '取消',
			 		type: 'warning',
			 		customClass: 'confirm-them',
			 	}).then(() => {
			 		// this.$router.back(1)
			 		let query = this.$route.query
			 		this.$router.push({path: '/exercises/wrong-exercises', query: query})

			 	}).catch(() => {});

			 },
		
	
			/**
			 * 选择的答案
			 * @DateTime 2019-08-22T10:14:19+0800
			 * @param    {[stong]}       selected    [选中的答案]
			 * @param    {[stong]}       list        [题型的索引]
			 * @param    {[stong]}       index       [试题的索引]
			 * @param    {[stong]}       key         [选择题的索引]
			 * @param    {[stong]}       id          [试题的 id]
			 * @param    {[stong]}       answer      [选择题的选项]
			 * @param    {[stong]}       type        [1. 单选题， 2.多选， 3.其他]
			 * @return   {[type]}                             [description]
			 */
			selectAnswer( selected ,list, index, id, answer, obj){


				if( selected ){
					if( !obj.answer.includes( answer ) ){
						obj.answer.push( answer );	
					}
				}else{
					if(obj.answer.includes( answer ) ){
						obj.answer.splice( obj.answer.indexOf(answer) , 1);
					}
				}

				obj.answer.length != 0 ? obj.qiang_bool = 1 : obj.qiang_bool = 0 
				obj.answer.length != 0 ? obj.html_bool = 4 : obj.html_bool = 0;

				// /*ABCD排序*/
				obj.answer.sort(function(a, b) {
					return a.localeCompare(b)
				})



				// console.log(this.questionTyle[list].children[index].answer, this.questionTyle);
				
			},
			/**
			 * 选择的答案
			 * @DateTime 2019-08-22T10:14:19+0800
			 * @param    {[stong]}       selected    [选中的答案]
			 * @param    {[stong]}       list        [题型的索引]
			 * @return   {[type]}                             [description]
			 */
			selectAnswerChange(obj, key){

				let type = parseInt(obj.type_id)
				switch(key){
					case 1:
						if (obj.answer == '') {

							obj.html_bool = 0 /*未答*/
						}else if (obj.answer == obj.correct_answer[0]) {
							obj.html_bool = 1 /*正确*/
						}else{
							obj.html_bool = 2 /*错误*/
						}
						obj.qiang_bool = 0;
						obj.disabled = true
					break;
					case 2:
							let answer = obj.answer.join();
							let correctAnswer = obj.correct_answer.join();

							if (obj.answer.length == 0) {

								obj.html_bool = 0 /*未答*/
							}else if (answer == correctAnswer) {
								obj.html_bool = 1 /*正确*/
							}else{
								obj.html_bool = 2 /*错误*/
							}
							obj.qiang_bool = 0
							obj.disabled = true
							// console.log(obj.answer);
					break;
					case 3:

						if (obj.answer == '') {

							obj.html_bool = 0 /*未答*/
						}else if (obj.answer != '') {
							obj.html_bool = 1 /*正确*/
						}else{
							obj.html_bool = 2 /*错误*/
						}
						obj.qiang_bool = 0
						obj.disabled = true
					break;
					case 4:
						let Editor = 'Ueditor'+obj.id

						this.$refs[Editor][0].setDisabled('fullscreen')
						if (obj.answer == '') {

							obj.html_bool = 0 /*未答*/
						}else if (obj.answer != '') {
							obj.html_bool = 1 /*正确*/
						}else{
							obj.html_bool = 2 /*错误*/
						}
						obj.qiang_bool = 0
					break;
					case 9:
						if (obj.answer == '') {

							obj.html_bool = 0 /*未答*/
						}else if (obj.answer == obj.correct_answer[0]) {
							obj.html_bool = 1 /*正确*/
						}else{
							obj.html_bool = 2 /*错误*/
						}
						obj.qiang_bool = 0;
						obj.disabled = true
						
					break;
				}
				// console.log(this.answerList);
				
			},
		}
	}
</script>